#@layout()

#define script()
<script>

    function trash(id) {
        ajaxGet("#(CPATH)/admin/article/doTrash/" + id);
    }


    function draft(id) {
        ajaxGet("#(CPATH)/admin/article/doDraft/" + id);
    }

    function normal(id) {
        ajaxGet("#(CPATH)/admin/article/doNormal/" + id);
    }

    function del(id) {
        if (confirm("确定要删除该页面吗？删除后不可恢复")) {
            ajaxGet("#(CPATH)/admin/article/doDel/" + id);
        }
    }

</script>

#end


#define content()
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-6">

                    <div class="row mb-2">
                        <div class="col-sm-12">
                            <h1>
                                文章管理
                                <small data-toggle="tooltip" title="可以查看所有文章，鼠标移到文章标题上，可以对其编辑或删除等操作" data-placement="bottom"
                                       data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                                <small> 首页 / 文章 / 文章管理</small>
                            </h1>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-12" style="padding-top: 20px">
                            <a href="?">全部 (#(totalCount ??))</a> |
                            <a href="?status=normal">已发布 (#(normalCount ??))</a> |
                            <a href="?status=draft">草稿 (#(draftCount ?? 0))</a> |
                            <a href="?status=trash" style="color: #a00">垃圾箱 (#(trashCount ?? 0))</a>
                        </div>
                    </div>

                </div>
                <div class="col-sm-6 ">
                    <div class=" float-sm-right" style="padding-top: 45px">
                        <a href="./write" type="button" class="btn btn-primary"><i class="fas fa-plus"></i>新建</a>
                    </div>
                </div>
            </div>

        </div><!-- /.container-fluid -->
    </section>



    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="card card-outline card-primary">
                <div class="card-header">
                    <form class=" admin-search-panel" action="" method="get">
                        <div class="row">
                            <div class="form-group col-lg-2">
                                <input type="text" class="form-control" placeholder="请输入标题" name="title" value="#para('title')">
                            </div>
                             <div class="form-group col-lg-2">
                                 <select class="form-control" name="categoryId">
                                     <option value="">全部分类</option>
                                     #for(category : categories)
                                     <option value="#(category.id ??)" #selectedIf(category.id == numberPara('categoryId'))>#(category.title ??)</option>
                                     #end
                                 </select>
                            </div>
                            <div class="form-group col-lg-2">
                                <button type="submit" class="btn btn-primary ">查询</button>
                                <button type="reset" class="btn btn-default">重置</button>
                            </div>
                        </div>

                        <!-- /.card-body -->
                    </form>
                </div> <!-- /.card-body -->
                <div class="card-body p-0">

                    <table class="table table-striped table-action">
                        <thead>
                            <tr>
                                <th style="width: 10px">
                                    <input class="tableCheckAll"  type="checkbox">
                                </th>
                                <th style="width: 450px">标题</th>
                                <th>固定链接</th>
                                <th>样式</th>
                                <th style="width: 100px">发布时间</th>
                            </tr>
                        </thead>
                        <tbody>


                        #for(item : page.list ??)
                        <tr >
                            <td>
                                <input name="tableItem"  type="checkbox" value="#(item.id)"/>
                            </td>
                            <td>
                                <strong>
                                    <a href="#(CPATH)/admin/article/write/#(item.id)">#(item.title ??)</a>
                                    #if(item.isDraft())
                                    （草稿）
                                    #end
                                </strong>
                                <div class="jp-action-card">
                                        #if(item.isNormal())
                                        <div class="jp-action-body">
                                            <a href="#(CPATH)/admin/article/write/#(item.id)">编辑</a> |
                                            <a href="javascript:;" onclick="draft('#(item.id??)')">草稿</a>
                                            |
                                            <a href="javascript:;" onclick="trash('#(item.id??)')"
                                               class="red-action">垃圾箱</a> |
                                            <a href="#(item.url ??)" target="_blank" class="red-action">查看</a>
                                        </div>
                                        #elseif(item.isDraft())
                                        <div class="jp-action-body">
                                            <a href="#(CPATH)/admin/article/write/#(item.id)">编辑</a> |
                                            <a href="javascript:;" onclick="trash('#(item.id??)')"
                                               class="red-action">垃圾箱</a>
                                        </div>
                                        #else
                                        <div class="jp-action-body">
                                            <a href="javascript:;" onclick="draft('#(item.id??)')">还原</a>
                                            |
                                            <a href="javascript:;" onclick="del('#(item.id??)')" class="red-action">永久删除</a>
                                        </div>
                                        #end
                                </div>
                            </td>
                            <td>#(item.slug ??)</td>
                            <td>#(item.style ?? "默认")</td>
                            <td>#date(item.created ??)</td>
                        </tr>
                        #end

                        </tbody>
                    </table>


                    <div class="card-footer">
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="row">

                                    <div class="form-group">
                                        <div class="form-check">
                                            <input class="form-check-input tableCheckAll" id="checkall" type="checkbox" >
                                            <label class="form-check-label" for="checkall">全选</label>
                                        </div>
                                    </div>
                                    <div class="form-group col-lg-3">
                                        <select class="form-control" name="action">
                                            <option value="">请选择...</option>
                                            <option value="doDelByIds" open-type="del-confirm">
                                                批量删除
                                            </option>
                                        </select>
                                    </div>

                                    <div class="form-group col-lg-3">
                                        <button type="button" class="btn btn-outline-primary batchExec">批量操作</button>
                                    </div>
                                </div>
                            </div>

                            <div class="col-sm-6">
                                #@_paginate()
                            </div>
                        </div>
                    </div>
                    <!-- /.card-footer -->


                </div><!-- /.card-body -->


            </div>
        </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->

#end